package com.itcast.web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/demo02")
public class ServletDemo02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doget...");
        String queryString = req.getQueryString();
        System.out.println(queryString);
        String[] params = queryString.split("&");
        String[] userName = params[0].toString().split("=");
        String[] password = params[1].toString().split("=");
        System.out.println(userName[0]+"------"+userName[1]);
        System.out.println(password[0]+"------"+password[1]);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("dopost...");
        String queryString = req.getQueryString();
        System.out.println(queryString);
    }
}
